<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page isELIgnored="false" %> 

<%@ page import="net.ssta.core.db.RecordSet"%>
<%@ page import="net.ssta.core.db.Record"%>
<%@ page import="net.ssta.core.db.PagingInfo"%>

<%
	String path = request.getContextPath();
	//分页参数
    PagingInfo pagingInfo =(PagingInfo) request.getAttribute("pagingInfo");
    
	RecordSet rs=(RecordSet)request.getAttribute("RECORDSET");
	if(rs==null){rs=new RecordSet();}
	
	 int pageno = pagingInfo.getCurrentPageNo();
	 Record  searRecord=(Record)request.getAttribute("searchData");
	 if(searRecord==null){
		 searRecord=new Record();
	 }
%>


 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<link type="text/css" rel="stylesheet" href="<%=path %>/includes/css/commonStyle.css"/> 
<link type="text/css" rel="stylesheet" href="<%=path %>/includes/styleBase/css/styleBase.css"/>
<link type="text/css" rel="stylesheet" href="<%=path %>/includes/styleBase/css/ostable.css" />
<link rel="stylesheet" href="<%=path %>/includes/lhgdialog/lhgdialog.css" />


<script type='text/javascript' src="<%=path %>/includes/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/includes/styleBase/js/style.js"></script>
<script type="text/javascript" src="<%=path %>/includes/DatePicker/WdatePicker.js"></script>


<script type="text/javascript" src="<%=path %>/includes/lhgdialog/lhgcore.min.js"></script>
<script type="text/javascript" src="<%=path %>/includes/lhgdialog/lhgdialog.js"></script>



<title>注册用户管理</title>
 
<script type="text/javascript">
	 function addUser()
	{
		var dlg = new J.ui.dialog(
		{ id:'handledemand',
	         title:'新增前台用户',
	         range:true,
	         btns:true,
	         page:'<%=path%>/back/registerUser/addUser.jsp',
	         width:600,
	         height:520,
	         windowObj:window
	       });
		dlg.ShowDialog();
	}
	
 
	
	function moduser()
	{
	
		var v=$("input:[name=userId]:checked").val();
		if(v==null){
		  alert("您必须选择一个用户");
		  return;
		}
		var dlg = new J.ui.dialog(
		{ id:'handledemand',
	         title:'修改用户信息',
	         range:true,
	         btns:true,
	         page:'<%=path%>/back/registerUser/modUser.jsp?userId='+v,
	         width:500,
	         height:500,
	         windowObj:window
	       });
		dlg.ShowDialog();
	}
	
	
	function deleteUser()
	{
	
			var v=$("input:[name=userId]:checked").val();
			if(v==null){
			  alert("您必须选择一个用户");
			  return;
			}
		
	 	  $.ajax({ 
			type: "POST", url: "<%=path%>/back/userManager?method=delUser",
			data:'userId='+v,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function (msg) {
				if("true"==msg){
				   alert("冻结用户成功");
				   reloadPage();
				}else{
					alert("冻结用户失败，请稍候重试！");
				}
			}
		}); 
	}
	
	function openUser()
	{
	
			var v=$("input:[name=userId]:checked").val();
			if(v==null){
			  alert("您必须选择一个用户");
			  return;
			}
		
	 	  $.ajax({ 
			type: "POST", url: "<%=path%>/back/userManager?method=openUser",
			data:'userId='+v,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function (msg) {
				if("true"==msg){
				   alert("解除冻结用户成功");
				   reloadPage();
				}else{
					alert("解除冻结用户失败，请稍候重试！");
				}
			}
		}); 
	}
	
	function sendMail()
	{
	
			var v=$("input:[name=userId]:checked").val();
			var uname=$("input:[name=userId]:checked").attr("uName");
			if(v==null){
			  alert("您必须选择一个用户");
			  return;
			}
		
	 	  $.ajax({ 
			type: "POST", url: "<%=path%>/back/userManager?method=ajaxSendMail",
			data:'userId='+v+"&userName="+uname,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function (msg) {
				if("true"==msg){
				   alert("发送激活邮件给用户成功");
				   reloadPage();
				}else{
					alert("发送激活邮件给用户失败，请稍候重试！");
				}
			}
		}); 
	}
	function resetPwd()
{

		var v=$("input:[name=userId]:checked").val();
		
		var dlg = new J.ui.dialog(
		{ id:'handledemand',
          title:'重置密码',
          range:true,
          btns:true,
          page:'<%=path%>/back/registerUser/resetPwd.jsp?userId='+v,
          width:400,
          height:220,
          windowObj:window
        });
		dlg.ShowDialog();
}
	
	//跳转
	function reloadPage() 
	{
		_goPage(<%=pageno%>);
	}
</script>

</head>
<body>
 
	<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left">&nbsp;</td>
      <td class="box_top_center">用户信息查询</td>
      <td class="box_top_right">&nbsp;</td>
    </tr>
  </table>
</div>

<form name="_sForm" action="<%=path %>/back/userManager" method="post">
	<div class="infoDiv">
	  <table border="0" cellpadding="0" cellspacing="0" class="trHeightTable">
	    <tr>
	      <td class="leftTipArea">用户名：</td>
	      <td><input  name="search_LOGINNAME" class="textInput" style="width:120px;" value="<%=searRecord.getString("LOGINNAME","") %>"/></td>
	    
	      <td width="10px">&nbsp;</td>
	      
		   <td class="leftTipArea">真实姓名：</td>
	      <td><input  name="search_USERNAME" class="textInput" style="width:120px;" value="<%=searRecord.getString("USERNAME","") %>"/></td>
	     <td width="20px">&nbsp;</td>
	      <td>
	      	<a href="javascript:document._sForm.submit()" class="imgButton"  ><span>查询</span></a>
	      </td>
	    </tr>
	  </table>
	</div>
</form>

<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left" width="2">&nbsp;</td>
      <td class="box_top_center">查询结果列表</td>
      <td class="box_top_right" width="2">&nbsp;</td>
    </tr>
  </table>
</div>

<div class="contentBox">
    <table class="osTable" cellpadding="0" cellspacing="0" border="0">
      <thead>
        <tr >
          <th  width="5%" >选择</th>
          <th  width="10%" >用户名</th>
          <th  width="10%" >真实姓名</th>
          <th  width="6%">性别</th>
          <th  width="15%">Email</th>
          <th  width="15%">出生年月</th>
          <th  width="15%">电话</th>
          <th  width="15%">激活状态</th>
          <th  width="15%">冻结状态</th>
        </tr>
      </thead>
      <tbody>
        <%
           int i=0;
           for(i=0;i<rs.size();i++){
        	   Record r=rs.get(i);
        	   String birthDay=r.getString("BIRTHDAY","");
        	   if(birthDay.length()>10){
        		   birthDay=birthDay.substring(0,10);
        	   }
        	   String deltag=r.getString("DELTAG","");
        	   String verifyID=r.getString("VERIFYID","");
        %>
	 
	 <tr>
	    <td><input type="radio" value="<%=r.getString("USERID","") %>" name="userId" uName="<%=r.getString("LOGINNAME","") %>"/>&nbsp;</td>
	    <td><%=r.getString("LOGINNAME","") %>&nbsp;</td>
	    <td><%=r.getString("FULLNAME","") %>&nbsp;</td>
	    <td><%=r.getString("SEX","") %>&nbsp;</td>
	    <td><%=r.getString("EMAIL","") %>&nbsp;</td>
	    <td><%=birthDay %>&nbsp;</td>
	    <td><%=r.getString("TELEPHONE","") %>&nbsp;</td>
	    <td><%
	     		if("true".equals(deltag)&&!"".equals(verifyID)){
	     			out.println("未激活");
	     		}else{
	     			out.println("正常");
	     		}
	     	 %></td>
	    <td><%
	     		if("true".equals(deltag)&&"".equals(verifyID)){
	     			out.println("已冻结");
	     		}else{
	     			out.println("正常");
	     		}
	     	 %>
	    </td>
	 </tr>
	 <%} for(;i<10;i++){%>
	<tr>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	    <td>&nbsp;</td>
	 </tr>
	 <%} %>
      </tbody>
    </table>
	<div class="navDiv">
    <div class="navLeftDiv">
        <a href="#2010" class="imgButton"  onclick="resetPwd()"><span>重置密码</span></a>
        <a href="#2010" class="imgButton"  onclick="addUser()"><span>增加</span></a>
        <a href="#2010" class="imgButton"  onclick="moduser()"><span>修改</span></a>
        <a href="#2010" class="imgButton"  onclick="sendMail()"><span>发送激活邮件</span></a>
        <a href="#2010" class="imgButton"  onclick="deleteUser()"><span>冻结</span></a>
        <a href="#2010" class="imgButton"  onclick="openUser()"><span>解除冻结</span></a>
    </div>
    
    <div class="navRightDiv">  
    	 <jsp:include flush="true" page="/common/paging.jsp"></jsp:include>
	</div>
</div>
</div>
</body> 
</html>